package com.thb.user.validation;

import com.thb.exception.ExceptionCodeUtil;
import com.thb.exception.ServiceException;
import com.thb.utils.ValidationUtil;

public class ValidateUser {
	
	public static void validUser(String email,String passwd){
		
		if(email == null || "".equals(email)){
			throw new ServiceException(ExceptionCodeUtil.ValidErrorCode, "邮件不能为空");
		}
		
		if(passwd == null || "".equals(passwd)){
			throw new ServiceException(ExceptionCodeUtil.ValidErrorCode, "密码不能为空");
		}
		
		if(email.length() > 20){
			throw new ServiceException(ExceptionCodeUtil.ValidErrorCode, "邮件长度不能超过20位");
		}
		
		if(!ValidationUtil.isMail(email)){
			throw new ServiceException(ExceptionCodeUtil.ValidErrorCode, "邮件格式不正确");
		}
		
		
	}

}
